package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.system.domain.entity.Employee;
import com.ruoyi.system.domain.entity.ServiceRecord;
import com.ruoyi.system.mapper.EmployeeMapper;
import com.ruoyi.system.mapper.ServiceRecordMapper;
import com.ruoyi.system.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee> implements IEmployeeService {
    @Autowired
    private ServiceRecordMapper serviceRecordMapper;

    @Override
    public Employee getWithServiceRecords(Long id) {
        Employee employee = this.getById(id);
        if (employee != null) {
            List<ServiceRecord> serviceRecords = serviceRecordMapper.selectByEmployeeId(id);
            employee.setServiceRecords(serviceRecords);
        }
        return employee;
    }
}